package main

import (
	"com.smyx/cache"
	"com.smyx/initialize"
	"com.smyx/mqtt"
	"com.smyx/util"
	"fmt"
	"go.uber.org/zap"
	"time"
)

func main() {
	// 读取config.json文件
	initialize.LoadAgentConfig()
	// 初始化日志框架
	if "dev" == cache.CfgStruct.Mode {
		util.InitDevLogger()
	} else {
		util.InitProdLogger()
	}
	defer func(SugarLogger *zap.SugaredLogger) {
		err := SugarLogger.Sync()
		if err != nil {
			fmt.Println(err)
		}
	}(util.SLogger)
	// 订阅主题
	mqtt.InitMqttConfig()
	for _, topic := range cache.CfgStruct.MqttConfig.Topics {
		util.SLogger.Infof("开始订阅主题[%v]", topic)
		mqtt.Subscribe(topic)
	}
	util.SLogger.Info(">>>>>>>>>>>>>>>>服务启动完成>>>>>>>>>>>>>>>>")
	for !cache.IsStop {
		time.Sleep(1 * time.Second)
	}
}
